######################################################
#Figure D4: Unemployment Spending and Social Spending
#Author: Raluca L. Pahontu
#####################################################

mydata3 <- read.dta13("dataunemplsocial.dta")
counts <- table(mydata3$unempl_spending, mydata3$social_spending)
percentages <- prop.table(counts,1) 
df <- as.data.frame(percentages) 

lim <- c(0, max(df$Freq) + 0.2)

ggplot(df, aes(x=Var2, y=Freq, group=Var1)) + 
  geom_bar(aes(fill = Var1), stat="identity", position = "dodge", width = .5)  + 
  ylab("Percent") + xlab("Social Spending") + 
  scale_fill_manual(labels=c("Less", "Same", "More"), values=c("grey80", "grey60", "grey40"), name= "Unemployment Spend")+ 
  scale_x_discrete(labels=c("Less", "Same", "More")) +
  scale_y_continuous(limits=lim, expand= c(0,0)) + theme_bw() 
ggsave(file="figure_d4.eps")



